#include "ScnsSmctp.c.h"

#if defined(SCNS_SMCTP_ENABLE)&&SCNS_SMCTP_ENABLE==1

#include "ScnsMenu.h"
#include "ScnsMath.h"
#include "ScnsTimer.h"
#include "ScnsLed.h"

const ScnsSmctpChanelConfig scnsSmctpChanelConfig[SCNS_SMCTP_CHANNEL_MAX]={
    [SCNS_SMCTP_CHANNEL_MENU]={.callback=scnsMenuReceiveInterrupt},

};

ScnsStatus scnsBspSmctpInit(void)
{
    scnsCheckTimeOut(100000,SCNS_STATUS_OK==scnsBspSmctpCanSend(),SCNS_STATUS_FULL);
    uart_init(UART_3,460800,UART3_MAP0_TX_B10,UART3_MAP0_RX_B11);
    uart_tx_dma_init(UART_3,3<<5);
    uart_rx_dma_init(UART_3,4<<5);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspSmctpCanSend(void)
{
    return SCNS_STATUS_OK;
}

void scnsBspSmctpSend(const uint8*buf,uint32*len)
{
    uart_tx_dma_start(UART_3,buf,*len);
}

void scnsBspSmctpReceiveIdleDmaStart(uint8*buf,uint32 len)
{
    uart_rx_dma_start(UART_3,buf,len);
}

void scnsBspSmctpReceiveIdleDmaStop(uint8*buf,uint32 len)
{
    uart_rx_dma_stop(UART_3);
}

int32 scnsBspSmctpReceiveIdleDmaGetLength(void)
{
    return -DMA_CH(uart_rx_dma[UART_3])->CNTR;
}

#endif
